home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: clientConnect.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:54 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
- #include "sysdefs.h"
- #include <fcntl.h>
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "semaphore.h"
- #include "link.h"
- #include "host.h"
- #include "bitvec.h"
- #include "msgvector.h"
- #include "latch.h"
- #include "bf.h"
- #include "lsn.h"
- #include "volume.h"
- #include "openlog.h"
- #include "msg_funcs.h"
- #include "util_funcs.h"
- #include "thread_funcs.h"
- #include "msg_globals.h"
- #include "log_globals.h"
- #include "disk_globals.h"
-
-
- void
- clientConnect (
-
- register LINK *link
- )
- {
-
- register int fd;
- int length;
- int socketBufSize = 16*1024; /* 16K socket buffers */
-
- TRPRINT(TR_MSG, TR_LEVEL_1, ("accepting on socket:%d", link->id));
-
- /*
- * set the address length
- */
- length = sizeof(SOCKADDR);
- TRPRINT(TR_MSG, TR_LEVEL_2, ("length:%d", length));
-
- /*
- * do an accept
- */
- if ((fd = accept(link->id, (struct sockaddr *) &(link->address), &length)) < 0) {
-
- SM_ERROR(TYPE_FATAL, errno);
- }
- TRPRINT(TR_MSG, TR_LEVEL_2, ("fd:%d client inet addr:%s", fd,
- inet_ntoa(*(struct in_addr *)&link->address.sin_addr.s_addr)));
-
-
-
- /*
- * Turn of TCP delay on the socket and increase the send and
- * receive buffer size
- */
- if (setSocketOptions(fd, socketBufSize, socketBufSize) != esmNOERROR) {
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- /*
- * set the socket to close on exec for disk processes
- */
- if (fcntl(fd, F_SETFD, NULL) < 0) {
-
- SM_ERROR(TYPE_FATAL, errno);
- }
-
- /*
- * get the new link
- */
- link = &(Links[fd]);
-
- SM_ASSERT(LEVEL_1, (link->linkClass == (CL_UNUSED | CL_TIMEDOUT)));
- SM_ASSERT(LEVEL_1, (link->flags == LINK_FREE));
- /*
- * set the type and state of the link
- */
- link->linkClass = CL_CLIENT;
- link->flags = LINK_ACCEPT;
- /* LINK_ACCEPT means we just accepted this cx and have not yet
- * received an INIT_CLIENT message
- */
-
- link->linkTransError = esmNOERROR;
-
- /*
- * set the select bit counter
- */
- setSelectBits(fd);
-
- /*
- * set the receive information
- */
- setLink(link);
-
- /*
- * inc the count of active clients (used to tell if we can
- * do disk i/o locally or have to pass it off to a disk process)
- */
- NumActiveClients++;
-
- /* return to main loop */
- }
-